package com.app.interceptor;

import org.apache.logging.log4j.Logger;

import com.app.conf.AppConfig;
import com.app.util.tools.ThreadCache;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

public class GlobalActionInterceptor implements Interceptor
{
	private Logger logger     = AppConfig.getAppConfig().getLogger();
	
	private ThreadCache cache = AppConfig.getAppConfig().getCache();
	
	@Override
	public void intercept(Invocation invocation)
	{
		try
		{
			cache.add(invocation.getActionKey()+"\r\n");
			
			invocation.invoke();
		}
		finally
		{
			//输出日志
			logger.info(cache.get());
			cache.del();
		}
	}

}
